home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / com_and4.zip / OVERLAY.ASM < prev    next >
Assembly Source File  |  1990-03-22  |  3KB  |  109 lines

  1. page 48,132
  2. title    COM-AND script machine language subroutine
  3. ;-------------------------------------------------------------------
  4. ;    Author:      R. McGinnis; Chicago IL
  5. ;
  6. ;    These routines provide some simple functions in a machine
  7. ;    language overlay form for COM-AND scripts.
  8. ;
  9. ;    Source: OVERLAY.ASM    Source for this module
  10. ;    Object: OVERLAY.OBJ    Object derived from assembly of .Asm
  11. ;    Exec:    OVERLAY.EXE    Executable derived from LINK of .OBJ
  12. ;
  13. ;    Note: you'll need entry points for the script SCALL statement
  14. ;    Note: no stack segment is required
  15. ;-------------------------------------------------------------------
  16.  
  17.     PUBLIC    Display         ; Display a string
  18.  
  19. code    segment byte public 'code'
  20.     ASSUME    CS:Code
  21.  
  22.     jmp    near ptr Display    ; A jump table makes it easy
  23.     jmp    near ptr SegAddr    ; .. to SCALL a routine
  24.  
  25. page
  26. ;------ Display ----------------------------------------------------
  27. ;    This routine displays a string on the screen
  28. ;
  29. ;    Passed:
  30. ;       One parameter, the string addr
  31. ;    Returned:
  32. ;       nothing
  33. ;
  34. ;    No registers need be preserved...
  35. ;-------------------------------------------------------------------
  36.  
  37. Display proc    far            ; MUST be far return !!
  38. ;
  39. ;    Get passed parameters
  40. ;
  41.     mov    BP,SP            ; Save current stack ptr
  42.  
  43.     mov    SI,[BP+4]        ; Get offset of last parm
  44.     mov    ax,[BP+6]        ; Get segment of last parm
  45.     mov    DS,ax            ; And set into DS...
  46.  
  47. ;***    mov    DI,[BP+8]        ; Get offset of prev parm
  48. ;***    mov    ax,[BP+10]        ; Get segment of prev parm
  49. ;***    mov    ES,ax            ; Set segment into ES
  50. ;
  51. ;    Initialize
  52. ;
  53.     xor    cx,cx            ; Make cx = 0
  54.     mov    ah,0eh            ; Int 10h subfuntion, TTY write
  55.     xor    bx,bx            ; Make bh,bl = 0 (page # and fgnd)
  56. ;
  57. ;    Display the string one character at a time
  58. ;
  59. DISP100:
  60.     mov    al,byte ptr [SI]    ; Get a char
  61.     or    al,al            ; Test for null terminator
  62.     jz    DISP200         ; Skip if found
  63.  
  64.     int    10h            ; Write TTY (req's ah,al,bh,bl)
  65.  
  66.     inc    SI            ; Point next fetch
  67.     inc    cx            ; We'll display it
  68.     cmp    cx,80            ; Max length is 80
  69.     jl    DISP100         ; Loop up to 80 times
  70. ;
  71. ;    And we're done
  72. ;
  73. DISP200:
  74.     ret                ; FAR return here
  75. Display endp
  76. page
  77. ;------ SegAddr ----------------------------------------------------
  78. ;    This routine returns the overlay segment address
  79. ;
  80. ;    Passed:
  81. ;       nothing
  82. ;    Returned:
  83. ;       One parameter, the segment value
  84. ;
  85. ;    No registers need be preserved...
  86. ;-------------------------------------------------------------------
  87.  
  88. SegAddr proc    far            ; MUST be far return !!
  89. ;
  90. ;    Get rtn parameter address
  91. ;
  92.     mov    BP,SP            ; Save current stack ptr
  93.  
  94.     mov    DI,[BP+4]        ; Get offset of last parm
  95.     mov    ax,[BP+6]        ; Get segment of last parm
  96.     mov    DS,ax            ; And set into DS...
  97. ;
  98. ;    Store the segment reg
  99. ;
  100.     mov    ax,CS            ; Set-up to store
  101.     mov    word ptr DS:[DI],ax    ; Store our segment addr
  102. ;
  103. ;    And we're done
  104. ;
  105.     ret                ; FAR return here
  106. SegAddr endp
  107. Code    ends
  108.     end
  109.